﻿using System;
using System.IO;
using System.Reflection;

namespace WaveAccess.LZONet.TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            LZOCompressorException ex = new LZOCompressorException("");
            Console.WriteLine(LZOCompressor.Version);
            Console.WriteLine(LZOCompressor.FullVersion);
            LZOCompressor lzo1 = new LZOCompressor();
            Console.WriteLine(lzo1.ToString());
            LZOCompressor lzo = new LZOCompressor(CompressionAlgorithm.LZO1X112);
            FileStream fs = new FileStream("lgplv3.txt", FileMode.Open, FileAccess.Read);
            byte[] original = new byte[fs.Length];
            fs.Read(original, 0, (int)fs.Length);
            fs.Close();
            byte[] compressed = lzo.Compress(original);
            fs = new FileStream("lgplv3_comp.txt", FileMode.Create, FileAccess.Write);
            fs.Write(compressed, 0, compressed.Length);
            fs.Close();
            byte[] decompressedSafe = lzo.Decompress(compressed);
            fs = new FileStream("lgplv3_decomp_safe.txt", FileMode.Create, FileAccess.Write);
            fs.Write(decompressedSafe, 0, decompressedSafe.Length);
            fs.Close();
            byte[] decompressed = lzo.Decompress(compressed, false);
            fs = new FileStream("lgplv3_decomp.txt", FileMode.Create, FileAccess.Write);
            fs.Write(decompressed, 0, decompressed.Length);
            fs.Close();
            Console.WriteLine("Testing assembly attributes...");
            Assembly asm = Assembly.GetAssembly(typeof(LZOCompressor));
            Console.WriteLine((asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute).Description);
            Console.WriteLine((asm.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute).Title);
            Console.WriteLine((asm.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0] as AssemblyCompanyAttribute).Company);
            Console.WriteLine((asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute).Copyright);
            //Console.WriteLine((asm.GetCustomAttributes(typeof(AssemblyVersionAttribute), false)[0] as AssemblyVersionAttribute).Version);
            Console.WriteLine((asm.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false)[0] as AssemblyConfigurationAttribute).Configuration);
            Console.WriteLine("Cool. Press any key to exit now.");
            Console.ReadKey();
        }
    }
}
